﻿<%@ Page Language="C#" MasterPageFile="~/Template/Site_Main.Master" AutoEventWireup="true"
    CodeBehind="studentinfo_contrast.aspx.cs" Inherits="RegisterationSystem.Space_Education.studentinfo_contrast" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
      <!--
        $(function () {
            //设置导航位置
            setLocalToParent();
            //初始化隐藏层
            $('#plastudentinfo').dialog({   
                closed: true
            });
            $('#plastudentctinfo').dialog({   
                closed: true
            });
            var products = <%=ShcJson %>;


            //加载学校
         $("#selectddlSchoolInfo").combobox({
             url: "../SyncService/GetDataList.ashx?action=getschoolinfolistselect",
             // url: "../SyncService/GetDataList.ashx?action=GetCommList&parentID=0",
             valueField: 'id',
             textField: 'name',
             //加载后触发
             onLoadSuccess: function () {
                 var xuexdata = $('#selectddlSchoolInfo').combobox('getData');
                 if (xuexdata.length > 0) {
                     $("#selectddlSchoolInfo").combobox('select', xuexdata[0].id);
                 }
             },
             //选择触发
             onSelect: function (xuexdata) {
                 //学校编号
                 $("#<%= hidselectschoolID.ClientID %>").val(xuexdata.id);
             }
         });


             //初始化社区下拉菜单
            $("#pcommunity").combobox({
                url: "../SyncService/GetDataList.ashx?action=GetCommListAddAll&parentID=0",
                valueField: 'id',
                textField: 'name',
                //加载后触发
                onLoadSuccess: function () {
                    var sdata = $('#pcommunity').combobox('getData');
                    if (sdata.length > 0) {
                        $("#pcommunity").combobox('select', sdata[0].id);
                    }
                },
                //选择触发
                onSelect: function (sdata) {
                    //加载小区
                    $("#scommunity").combobox({
                        url: "../SyncService/GetDataList.ashx?action=GetCommListAddAll&parentID=" + sdata.id,
                        valueField: 'id',
                        textField: 'name',
                        //加载后触发
                        onLoadSuccess: function (xpd) {
                        var sdata = $('#scommunity').combobox('getData');
                            $('#scommunity').combobox("select", xpd[0].id);
                        },
                        //选择触发
                                               onSelect: function (sdata) {
                                                   $("#xcommunity").combobox({
                        url: "../SyncService/GetDataList.ashx?action=GetCommListAddAll&parentID=" + sdata.id,
                        valueField: 'id',
                        textField: 'name',
                        //加载后触发
                        onLoadSuccess: function (xpd1) {
                       
                            $('#xcommunity').combobox("select", xpd1[0].id);
                        }
                                                   
                                                   })
                                               }
                    })
                }
            });
            //初始化企业用户数据列表控件
            $("#dg").datagrid({
                idField: "id",      //标识字段,主键
                url: "../SyncService/GetDataList.ashx?action=getallstudentcompareinfolist",
                queryParams: { "where": "1=1"},
                pagination: true,   //是否开启分页
                rownumbers: true,   //行号
                pageSize: 10,
                pageNumber: 1,
                columns: [[
                             { field: 'ck', checkbox: true },
                            { field: 'truename', title: '学生姓名', width: 105, align: 'center' },
                            { field: 'birthday', title: '出生日期', width: 105, align: 'center', formatter: function (value, row, index) {
                                var temp = new Array();
                                temp = value.split(" ");
                                return temp[0];
                            }
                            },

                            { field: 'sex', title: '性别', width: 60, align: 'center', formatter: function (value, row) {
                                if (value) {
                                    return "女";
                                } else {
                                    return "男";
                                }
                            }
                            },
                            { field: 'idcardnumber', title: '证件号(身份证/护照)', width: 150, align: 'center' },
                            { field: 'permanentaddress', title: '户籍地址', width: 400, align: 'center' },
                            { field: 'id', title: '操作', width: 160,align: 'center', formatter: function (value, row) {
                                    var res = "<a href='javascript:void(0)'  onclick='GetByStudentInfo("+value+");'>查看详细信息</a>";
                                    res += "  <a href='javascript:void(0)'  onclick='GetByStudentCtInfo("+value+");'>查看对比信息</a>";
                                    return res;
                                }
                            }
                         ]],
                         rowStyler: function(index,row){
                           switch(row.compareresult){
                                case "0":
			                    //return 'background-color:white;';
                                break;
                                case "1":
			                    return 'background-color:#CDC673;';
                                break;
                                case "2":
			                    return 'background-color:#CDC5BF;';
                                break;
                                case "3":
			                    return 'background-color:#FF6A6A;';
                                break;
//                                default:
//                                return 'color:yellow;';
		                    }
	                     }

            })
        });
        //-->
        //查询
        function SelDistributedStuList1()
        {
        
            var SchID = "";
            SchID += $("#selectddlSchoolInfo").combobox("getValue");
            var where ="";
            where+= $("#selectddlSchoolInfo").combobox("getValue");//所属学校
//            $('#dg').datagrid({ url: "../SyncService/GetDataList.ashx?action=getallservicesdivisioninfolist", queryParams: { "SchID": SchID} });
            $('#dg').datagrid({ url: "../SyncService/GetDataList.ashx?action=getallstudentcompareinfolist1", queryParams: { "where": where} });
            $('#dg').datagrid('reload');
        }
        //统计
        function SelDistributedStuList()
        {
            var where ="";
            where+=$("#scommunity").combobox("getValue")+",";//住房社区
            where+=$("#xcommunity").combobox("getValue")+",";//住房小区
            where+=$("#pcommunity").combobox("getValue")+"";//住房小区
            $('#dg').datagrid({ url: "../SyncService/GetDataList.ashx?action=getallstudentcompareinfolist", queryParams: { "where": where} });
            $('#dg').datagrid('reload');
        }

        //弹出学生详细信息
        function GetByStudentInfo(stdID) {
            $.post("../SyncService/GetDataList.ashx", 
                { "action": "GetStudentByID", "id": stdID }, 
                function (cStr) {
                    var stdInfo= eval('(' + cStr + ')');
                    $("#<%= hidstuID.ClientID %>").val(stdID);
                    $("#spanname").text(stdInfo.name);//姓名
                    $("#spansex").text(stdInfo.sex);//性别
                    $("#spanbirthday").text(stdInfo.birthday);//出生年月
                    $("#spanidcardnumber").text(stdInfo.idcardnumber);//学生身份证
                    $("#HouseIngoingTime").text(stdInfo.HouseIngoingTime);//户口迁入时间
                    $("#HousingOccupancyTime").text(stdInfo.HousingOccupancyTime);//住房入住时间
                    $("#PermanentAddress").text(stdInfo.PermanentAddress);//户籍地址
                   // $("#spanhobby").text(stdInfo.hobby);//兴趣爱好
                    $("#spanfirstguardianname").text(stdInfo.firstguardianname);//第一监护人
                    $("#spanfirstguardianunit").text(stdInfo.firstguardianunit);//工作单位
                    $("#spanfirstguardianphone").text(stdInfo.firstguardianphone);//联系电话
                    $("#spansecguardianname").text(stdInfo.secguardianname);//第二监护人
                    $("#spansecguardianunit").text(stdInfo.secguardianunit);//工作单位
                    $("#spansecguardianphone").text(stdInfo.secguardianphone);//联系电话
                    switch (stdInfo.houseareaid) {
                        case "0":
                        $("#spanhouseareaid").text("武汉经济技术开发区（汉南区）");//户口所在地
                        break;
                        case "1":
                        $("#spanhouseareaid").text("市内其它区");//户口所在地
                        break;
                        case "2":
                        $("#spanhouseareaid").text("省内市外、外省外市");//户口所在地
                        break;
                         case "3":
                        $("#spanhouseareaid").text("外籍(含港澳台)"); //户口所在地
                        break;
                    }
                    $("#spanpcommname").text(stdInfo.pcommname);
                    $("#spanscommname").text(stdInfo.scommname);//住房社区
                    $("#spanxcommname").text(stdInfo.xcommname);//住房小区
                    $("#spanhousenumber").text(stdInfo.housenumber);//门牌号
                    $("#spanhousecard").text(stdInfo.housecard);//房产号
                    $("#spanfirstrelationship").text(stdInfo.firstrelationship);//与学生关系
                    $("#spansecrelationship").text(stdInfo.secrelationship);//与学生关系
                },
                "text");
            //弹层
            $('#plastudentinfo').dialog({
                title: '学生信息',
                width: 600,
                height: 425,
                closed: false,
                cache: false,
                modal: true,
                collapsible: true,
                maximizable: false
            });
        }
        //弹出学生详细信息
        function GetByStudentCtInfo(stdID) {
            //alert(stdID);
            $("#dgCt").datagrid({
                idField: "id",      //标识字段,主键
                url: "../SyncService/GetDataList.ashx?action=getstudentctbyid",
                queryParams: { "where": "1=1", "id": stdID },
                pagination: true,   //是否开启分页
                rownumbers: true,   //行号
                pageSize: 10,
                pageNumber: 1,
                columns: [[
                            { field: 'ctname', title: '学生姓名', width: 105, align: 'center' },
                            { field: 'ctbirthday', title: '出生日期', width: 105, align: 'center', formatter: function (value, row, index) {
                                var temp = new Array();
                                temp = value.split(" ");
                                return temp[0];
                            }
                            },

                            { field: 'ctsex', title: '性别', width: 60, align: 'center', formatter: function (value, row) {
                                if (value) {
                                    return "女";
                                } else {
                                    return "男";
                                }
                            }
                            },
                            { field: 'ctaddress', title: '户籍地址', width: 400, align: 'center' },
                            { field: 'ctguardname', title: '户主姓名', width: 80, align: 'center' },
                            { field: 'ctguardrelation', title: '与户主户主', width: 80, align: 'center' }
                         ]],
                         onLoadSuccess:function(data){
                            var data=$('#dgCt').datagrid('getData');
//                            alert(data.total);
                            if(data.total == 0){
                                $.messager.alert("消息提示", "查无此人！");
                            }else{
                               //弹层
                                $('#plastudentctinfo').dialog({
                                    title: '学生对比信息',
                                    width: 900,
                                    closed: false,
                                    cache: false,
                                    modal: true,
                                    collapsible: true,
                                    maximizable: false
                                }); 
                            }
                         }
            }); 
        }
        //重置学生用户密码
        function UpdStudentPswdReset(StudentPswd) {
            $.messager.confirm('提示', '确认重置密码？', function (r) {
                if (r) {
                    $.post(location.href, { "action": "pswdreset", "id": $("#<%= hidstuID.ClientID %>").val(), "StudentPswd": StudentPswd }, function (data) {
                        $.messager.alert("消息提示", "重置成功！");
                         $('#plastudentinfo').dialog("close");
                        $('#dg').datagrid('reload');
                    });
                }
            });
        }


                        //把符合条件选定的数据导出excel
        function derive_excel() {
            var mess = "";
            var altmess = "";
                mess = "确认导出excel？";
                altmess = "导出excel成功!"
            //id集合
            var ids = "";
            //获取选择集合
            var rows = $('#dg').datagrid('getSelections');
            if (rows.length == 0) {
                alert("请选择行");
                return false;
            }
            //遍历选择行
            for (var i = 0; i < rows.length; i++) {
                ids += rows[i].id + ",";
            }

            $.messager.confirm('提示', mess, function (r) {
                if (r) {
                    $.ajax({
                        type: "POST",
                        url: "../SyncService/EduExcelHelper.ashx?type=derive_excelList&id=" + ids,
                        //                data: { "type": "loadReport", "typeid": "0", "where": "" + where + "" },
                        datatype: "text",
                        cache: false,
                        success: function (data) {
                            if (data == "0") {
                                alert("导出excel失败");
                            }
                            else {
                                try {
                                    window.location = data;
                                } catch (e) {

                                }
                            }
                        }
                    });
                }
            });
//            $.messager.confirm('提示', mess, function (r) {
//                if (r) {
//                    $.post(location.href, { "action": "derive_excelList", "id": ids }, function (data) {
//                        window.location = data;
//                    });

//                }
//            });
}

//把符合条件的所以数据导出excel
function derive_excelAll() {
   var mess = "";
   mess = "确认导出excel？";
    var where ="";
            where+=$("#scommunity").combobox("getValue")+",";//住房社区
            where+=$("#xcommunity").combobox("getValue")+",";//住房小区
             where+="";
            $.messager.confirm('提示', mess, function (r) {
                if (r) {
                    $.ajax({
                        type: "POST",
                        url: "../SyncService/EduExcelHelper.ashx?type=derive_excelListAllDaoChu&typeid=1&where=" + where,
                        //                data: { "type": "loadReport", "typeid": "0", "where": "" + where + "" },
                        datatype: "text",
                        cache: false,
                        success: function (data) {
                            if (data == "0") {
                                alert("导出excel失败");
                            }
                            else {
                                try {
                                    window.location = data;
                                } catch (e) {

                                }
                            }
                        }
                    });
                }
            });
//            $.messager.confirm('提示', mess, function (r) {
//        if (r) {
//            $.post(location.href, { "action": "derive_excelListAll", "where": where,"typeid":"2" }, function (data) {
//                window.location = data;
//            });

//        }
//    });
}
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Place_Local" runat="server">
    <div class="localTitle">
        <a>学生信息统计</a>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <!--选择的学生信息编号-->
    <asp:HiddenField ID="hidstuID" runat="server" />
         <!--所属学校查询时候用-->
    <asp:HiddenField ID="hidselectschoolID" runat="server" Value="0" />
    <div class="loadheight">
        <table width="100%%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td bgcolor="#FFFFFF">
                    <table width="100%%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td>
                                <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                </table>
                            </td>
                        </tr>
                    </table>
                    <table width="100%%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td class="cen_R_dh">
                                <strong>学生信息统计条件</strong>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <table width="100%" border="0" cellpadding="0" cellspacing="1">
                                    <tr>
                                        <td height="20">
                                            <table width="100%%" border="0" cellspacing="0" cellpadding="3">
                                            </table>
                                            <div style="margin-top: 5px">
                                            </div>
                                            <table width="688" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
                                                <tr>
                                                <td width="100" height="20" align="center" bgcolor="#FFFFFF">
                                                        住房片区
                                                    </td>
                                                    <td width="200" bgcolor="#FFFFFF">
                                                        <select id="pcommunity" class="easyui-combobox" data-options="editable:false" style="width: 120px;">
                                                        </select>
                                                    </td>
                                                    <td width="100" height="20" align="center" bgcolor="#FFFFFF">
                                                        住房社区
                                                    </td>
                                                    <td width="200" bgcolor="#FFFFFF">
                                                        <select id="scommunity" class="easyui-combobox" data-options="editable:false" style="width: 120px;">
                                                        </select>
                                                    </td>
                                                    <td width="100" align="center" bgcolor="#FFFFFF">
                                                        住房小区
                                                    </td>
                                                    <td align="left" bgcolor="#FFFFFF">
                                                        <select id="xcommunity" class="easyui-combobox" data-options="editable:false" style="width: 120px;">
                                                        </select>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                    <div style="margin-top: 5px">
                    </div>
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td width="200">
                                &nbsp;
                            </td>
                            <td>
                                <input type="button" name="button" id="button" value="统计" class="anniu" width="73"
                                    height="27" onclick="SelDistributedStuList();" />
                            </td>
                        </tr>
                    </table>


                    <%--<table width="100%%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td class="cen_R_dh">
                                <strong>按学校查询</strong>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <table width="100%" border="0" cellpadding="0" cellspacing="1">
                                    <tr>
                                        <td height="20">
                                            <table width="100%%" border="0" cellspacing="0" cellpadding="3">
                                            </table>
                                            <div style="margin-top: 5px">
                                            </div>
                                            <table width="250" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
                                                <tr>
                                                    <td width="50" height="20" align="center" bgcolor="#FFFFFF">
                                                        学校
                                                    </td>
                                                    <td width="60" align="left" bgcolor="#FFFFFF">
                                            <select id="selectddlSchoolInfo" class="easyui-combobox" data-options="required:true,editable:false"
                                    style="width: 125px;">
                                </select>
                                        </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>--%>
                    <%--<div style="margin-top: 5px">
                    </div>
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td width="100">
                                &nbsp;
                            </td>
                            <td>
                                <input type="button" name="button" id="button1" value="查询" class="anniu" width="73"
                                    height="27" onclick="SelDistributedStuList1();" />
                            </td>
                        </tr>
                    </table>--%>


                    <div style="height: 5px;">
                    </div>
                    <table width="100%%" border="0" cellspacing="0" cellpadding="1">
                        <tr>
                            <td class="cen_R_dh">
                                <strong>学生信息统计列表</strong>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <table width="100%%" border="0" cellspacing="0" cellpadding="1">
                                    <tr>
                                        <td style="background: #CDC673" width="60">
                                        </td>
                                        <td>
                                            不存在该学生的信息
                                        </td>
                                        <td style="background: #CDC5BF" width="60">
                                        </td>
                                        <td>
                                            该学生户籍信息不正确
                                        </td>
                                        <td style="background: #FF6A6A" width="60">
                                        </td>
                                        <td>
                                            该学生性别或出生日期不正确
                                        </td>
                                    </tr>
                                </table>
                                <!-- 创建数据列表控件 -->
                                <table id="dg">
                                </table>
                                <div style="height: 10px;">
                                </div>
                                <%-- <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                        <td align="left">
                                            <input type="button" name="button1" id="button3" value="选定导出Excel" class="anniu_big"
                                                width="73px" height="23px" onclick="derive_excel();" />
                                            <input type="button" name="button1" id="button4" value="全部导出Excel" class="anniu_big"
                                                height="23px" onclick="derive_excelAll();" />
                                        </td>
                                    </tr>
                                </table>--%>
                            </td>
                        </tr>
                    </table>
                    <!--弹出学生详细信息-->
                    <div id="plastudentinfo" class="easyui-dialog tcc_M">
                        <div class="tcc_div" style="margin-left: 20px;">
                            <ul>
                                <li class="tcc_BT">学生详细信息</li>
                                <li>姓名：<span id="spanname"></span></li>
                                <li>性别：<span id="spansex"></span></li>
                                <li>证件号(身份证/护照)：<span id="spanidcardnumber"></span>&nbsp;<a href='javascript:void(0)'
                                    onclick='UpdStudentPswdReset(123456);' style="color: #990000">密码重置</a></li>
                                <li>出生年月：<span id="spanbirthday"></span></li>
                                <li>户口所在地：<span id="spanhouseareaid"></span></li>
                                <li>住房片区：<span id="spanpcommname"></span></li>
                                <li>住房社区：<span id="spanscommname"></span></li>
                                <li>住房小区：<span id="spanxcommname"></span></li>
                                <li>门牌号：<span id="spanhousenumber"></span></li>
                                <li>房产证号：<span id="spanhousecard"></span></li>
                                <li>户口迁入时间：<span id="HouseIngoingTime"></span></li>
                                <li>住房入住时间：<span id="HousingOccupancyTime"></span></li>
                                <li>户籍地址：<span id="PermanentAddress"></span></li>
                                <%--<li>兴趣爱好：<span id="spanhobby"></span></li>--%>
                            </ul>
                        </div>
                        <div class="tcc_div" style="float: right">
                            <ul>
                                <li class="tcc_BT">监护人信息</li>
                                <li>第一监护人：<span id="spanfirstguardianname"></span></li>
                                <li>与学生关系：<span id="spanfirstrelationship"></span></li>
                                <li>工作单位：<span id="spanfirstguardianunit"></span></li>
                                <li>联系电话：<span id="spanfirstguardianphone"></span></li>
                                <li>&nbsp;</li>
                                <li>第二监护人：<span id="spansecguardianname"></span></li>
                                <li>与学生关系：<span id="spansecrelationship"></span></li>
                                <li>工作单位：<span id="spansecguardianunit"></span></li>
                                <li>联系电话：<span id="spansecguardianphone"></span></li>
                            </ul>
                        </div>
                    </div>
                    <div id="plastudentctinfo" class="easyui-dialog tcc_M">
                        <table id="dgCt">
                        </table>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
